import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

//解决动态路由报错问题
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location, onResolve, onReject) {
  if (onResolve || onReject)
    return originalPush.call(this, location, onResolve, onReject);
  return originalPush.call(this, location).catch(err => err);
};

const routes = [
  {
    path: "/login",
    name: "login",
    component: () =>
      import(/*webpackChunkName:"login"*/ "../pages/login/index.vue")
  },
  {
    path: "*",
    name: "404",
    component: () => import(/*webpackChunkName:"404"*/ "../pages/404/index.vue")
  }
];

const router = new VueRouter({
  routes
});

export default router;
